home *** CD-ROM | disk | FTP | other *** search
/ Champak 50 / Volume 50 - JOGO DISK .iso / Games / mallcrawl.swf / scripts / __Packages / mx / controls / Button.as next >
Encoding:
Text File  |  2007-09-28  |  8.6 KB  |  341 lines

  1. class mx.controls.Button extends mx.controls.SimpleButton
  2. {
  3.    var labelPath;
  4.    var initIcon;
  5.    var __width;
  6.    var __height;
  7.    var iconName;
  8.    var _iconLinkageName;
  9.    var hitArea_mc;
  10.    static var symbolName = "Button";
  11.    static var symbolOwner = mx.controls.Button;
  12.    var className = "Button";
  13.    static var version = "2.0.2.126";
  14.    var btnOffset = 0;
  15.    var _color = "buttonColor";
  16.    var __label = "default value";
  17.    var __labelPlacement = "right";
  18.    var falseUpSkin = "ButtonSkin";
  19.    var falseDownSkin = "ButtonSkin";
  20.    var falseOverSkin = "ButtonSkin";
  21.    var falseDisabledSkin = "ButtonSkin";
  22.    var trueUpSkin = "ButtonSkin";
  23.    var trueDownSkin = "ButtonSkin";
  24.    var trueOverSkin = "ButtonSkin";
  25.    var trueDisabledSkin = "ButtonSkin";
  26.    var falseUpIcon = "";
  27.    var falseDownIcon = "";
  28.    var falseOverIcon = "";
  29.    var falseDisabledIcon = "";
  30.    var trueUpIcon = "";
  31.    var trueDownIcon = "";
  32.    var trueOverIcon = "";
  33.    var trueDisabledIcon = "";
  34.    var clipParameters = {labelPlacement:1,icon:1,toggle:1,selected:1,label:1};
  35.    static var mergedClipParameters = mx.core.UIObject.mergeClipParameters(mx.controls.Button.prototype.clipParameters,mx.controls.SimpleButton.prototype.clipParameters);
  36.    var centerContent = true;
  37.    var borderW = 1;
  38.    function Button()
  39.    {
  40.       super();
  41.    }
  42.    function init(Void)
  43.    {
  44.       super.init();
  45.    }
  46.    function draw()
  47.    {
  48.       if(this.initializing)
  49.       {
  50.          this.labelPath.visible = true;
  51.       }
  52.       super.draw();
  53.       if(this.initIcon != undefined)
  54.       {
  55.          this._setIcon(this.initIcon);
  56.       }
  57.       delete this.initIcon;
  58.    }
  59.    function onRelease(Void)
  60.    {
  61.       super.onRelease();
  62.    }
  63.    function createChildren(Void)
  64.    {
  65.       super.createChildren();
  66.    }
  67.    function setSkin(tag, linkageName, initobj)
  68.    {
  69.       return super.setSkin(tag,linkageName,initobj);
  70.    }
  71.    function viewSkin(varName)
  72.    {
  73.       var _loc3_ = !this.getState() ? "false" : "true";
  74.       _loc3_ += !this.enabled ? "disabled" : this.phase;
  75.       super.viewSkin(varName,{styleName:this,borderStyle:_loc3_});
  76.    }
  77.    function invalidateStyle(c)
  78.    {
  79.       this.labelPath.invalidateStyle(c);
  80.       super.invalidateStyle(c);
  81.    }
  82.    function setColor(c)
  83.    {
  84.       var _loc2_ = 0;
  85.       while(_loc2_ < 8)
  86.       {
  87.          this[this.idNames[_loc2_]].redraw(true);
  88.          _loc2_ = _loc2_ + 1;
  89.       }
  90.    }
  91.    function setEnabled(enable)
  92.    {
  93.       this.labelPath.enabled = enable;
  94.       super.setEnabled(enable);
  95.    }
  96.    function calcSize(tag, ref)
  97.    {
  98.       if(this.__width == undefined || this.__height == undefined)
  99.       {
  100.          return undefined;
  101.       }
  102.       if(tag < 7)
  103.       {
  104.          ref.setSize(this.__width,this.__height,true);
  105.       }
  106.    }
  107.    function size(Void)
  108.    {
  109.       this.setState(this.getState());
  110.       this.setHitArea(this.__width,this.__height);
  111.       var _loc3_ = 0;
  112.       while(_loc3_ < 8)
  113.       {
  114.          var _loc4_ = this.idNames[_loc3_];
  115.          if(typeof this[_loc4_] == "movieclip")
  116.          {
  117.             this[_loc4_].setSize(this.__width,this.__height,true);
  118.          }
  119.          _loc3_ = _loc3_ + 1;
  120.       }
  121.       super.size();
  122.    }
  123.    function set labelPlacement(val)
  124.    {
  125.       this.__labelPlacement = val;
  126.       this.invalidate();
  127.    }
  128.    function get labelPlacement()
  129.    {
  130.       return this.__labelPlacement;
  131.    }
  132.    function getLabelPlacement(Void)
  133.    {
  134.       return this.__labelPlacement;
  135.    }
  136.    function setLabelPlacement(val)
  137.    {
  138.       this.__labelPlacement = val;
  139.       this.invalidate();
  140.    }
  141.    function getBtnOffset(Void)
  142.    {
  143.       if(this.getState())
  144.       {
  145.          var _loc2_ = this.btnOffset;
  146.       }
  147.       else if(this.phase == "down")
  148.       {
  149.          _loc2_ = this.btnOffset;
  150.       }
  151.       else
  152.       {
  153.          _loc2_ = 0;
  154.       }
  155.       return _loc2_;
  156.    }
  157.    function setView(offset)
  158.    {
  159.       var _loc16_ = !offset ? 0 : this.btnOffset;
  160.       var _loc12_ = this.getLabelPlacement();
  161.       var _loc7_ = 0;
  162.       var _loc6_ = 0;
  163.       var _loc9_ = 0;
  164.       var _loc8_ = 0;
  165.       var _loc5_ = 0;
  166.       var _loc4_ = 0;
  167.       var _loc3_ = this.labelPath;
  168.       var _loc2_ = this.iconName;
  169.       var _loc15_ = _loc3_.textWidth;
  170.       var _loc14_ = _loc3_.textHeight;
  171.       var _loc10_ = this.__width - this.borderW - this.borderW;
  172.       var _loc11_ = this.__height - this.borderW - this.borderW;
  173.       if(_loc2_ != undefined)
  174.       {
  175.          _loc7_ = _loc2_._width;
  176.          _loc6_ = _loc2_._height;
  177.       }
  178.       if(_loc12_ == "left" || _loc12_ == "right")
  179.       {
  180.          if(_loc3_ != undefined)
  181.          {
  182.             _loc3_._width = _loc9_ = Math.min(_loc10_ - _loc7_,_loc15_ + 5);
  183.             _loc3_._height = _loc8_ = Math.min(_loc11_,_loc14_ + 5);
  184.          }
  185.          if(_loc12_ == "right")
  186.          {
  187.             _loc5_ = _loc7_;
  188.             if(this.centerContent)
  189.             {
  190.                _loc5_ += (_loc10_ - _loc9_ - _loc7_) / 2;
  191.             }
  192.             _loc2_._x = _loc5_ - _loc7_;
  193.          }
  194.          else
  195.          {
  196.             _loc5_ = _loc10_ - _loc9_ - _loc7_;
  197.             if(this.centerContent)
  198.             {
  199.                _loc5_ /= 2;
  200.             }
  201.             _loc2_._x = _loc5_ + _loc9_;
  202.          }
  203.          _loc2_._y = _loc4_ = 0;
  204.          if(this.centerContent)
  205.          {
  206.             _loc2_._y = (_loc11_ - _loc6_) / 2;
  207.             _loc4_ = (_loc11_ - _loc8_) / 2;
  208.          }
  209.          if(!this.centerContent)
  210.          {
  211.             _loc2_._y += Math.max(0,(_loc8_ - _loc6_) / 2);
  212.          }
  213.       }
  214.       else
  215.       {
  216.          if(_loc3_ != undefined)
  217.          {
  218.             _loc3_._width = _loc9_ = Math.min(_loc10_,_loc15_ + 5);
  219.             _loc3_._height = _loc8_ = Math.min(_loc11_ - _loc6_,_loc14_ + 5);
  220.          }
  221.          _loc5_ = (_loc10_ - _loc9_) / 2;
  222.          _loc2_._x = (_loc10_ - _loc7_) / 2;
  223.          if(_loc12_ == "top")
  224.          {
  225.             _loc4_ = _loc11_ - _loc8_ - _loc6_;
  226.             if(this.centerContent)
  227.             {
  228.                _loc4_ /= 2;
  229.             }
  230.             _loc2_._y = _loc4_ + _loc8_;
  231.          }
  232.          else
  233.          {
  234.             _loc4_ = _loc6_;
  235.             if(this.centerContent)
  236.             {
  237.                _loc4_ += (_loc11_ - _loc8_ - _loc6_) / 2;
  238.             }
  239.             _loc2_._y = _loc4_ - _loc6_;
  240.          }
  241.       }
  242.       var _loc13_ = this.borderW + _loc16_;
  243.       _loc3_._x = _loc5_ + _loc13_;
  244.       _loc3_._y = _loc4_ + _loc13_;
  245.       _loc2_._x += _loc13_;
  246.       _loc2_._y += _loc13_;
  247.    }
  248.    function set label(lbl)
  249.    {
  250.       this.setLabel(lbl);
  251.    }
  252.    function setLabel(label)
  253.    {
  254.       if(label == "")
  255.       {
  256.          this.labelPath.removeTextField();
  257.          this.refresh();
  258.          return undefined;
  259.       }
  260.       if(this.labelPath == undefined)
  261.       {
  262.          var _loc2_ = this.createLabel("labelPath",200,label);
  263.          _loc2_._width = _loc2_.textWidth + 5;
  264.          _loc2_._height = _loc2_.textHeight + 5;
  265.          if(this.initializing)
  266.          {
  267.             _loc2_.visible = false;
  268.          }
  269.       }
  270.       else
  271.       {
  272.          delete this.labelPath.__text;
  273.          this.labelPath.text = label;
  274.          this.refresh();
  275.       }
  276.    }
  277.    function getLabel(Void)
  278.    {
  279.       return this.labelPath.__text == undefined ? this.labelPath.text : this.labelPath.__text;
  280.    }
  281.    function get label()
  282.    {
  283.       return this.getLabel();
  284.    }
  285.    function _getIcon(Void)
  286.    {
  287.       return this._iconLinkageName;
  288.    }
  289.    function get icon()
  290.    {
  291.       if(this.initializing)
  292.       {
  293.          return this.initIcon;
  294.       }
  295.       return this._iconLinkageName;
  296.    }
  297.    function _setIcon(linkage)
  298.    {
  299.       if(this.initializing)
  300.       {
  301.          if(linkage == "")
  302.          {
  303.             return undefined;
  304.          }
  305.          this.initIcon = linkage;
  306.       }
  307.       else
  308.       {
  309.          if(linkage == "")
  310.          {
  311.             this.removeIcons();
  312.             return undefined;
  313.          }
  314.          super.changeIcon(0,linkage);
  315.          super.changeIcon(1,linkage);
  316.          super.changeIcon(3,linkage);
  317.          super.changeIcon(4,linkage);
  318.          super.changeIcon(5,linkage);
  319.          this._iconLinkageName = linkage;
  320.          this.refresh();
  321.       }
  322.    }
  323.    function set icon(linkage)
  324.    {
  325.       this._setIcon(linkage);
  326.    }
  327.    function setHitArea(w, h)
  328.    {
  329.       if(this.hitArea_mc == undefined)
  330.       {
  331.          this.createEmptyObject("hitArea_mc",100);
  332.       }
  333.       var _loc2_ = this.hitArea_mc;
  334.       _loc2_.clear();
  335.       _loc2_.beginFill(16711680);
  336.       _loc2_.drawRect(0,0,w,h);
  337.       _loc2_.endFill();
  338.       _loc2_.setVisible(false);
  339.    }
  340. }
  341.